/**
 * FileName: SysLogServiceImpl
 * Author:   秋水浮萍
 * Date:     2020/8/23 20:19
 * Description:
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package com.demo.service.impl;

import com.demo.entity.*;
import com.demo.mapper.SysLogMapper;
import com.demo.service.SysLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
 * 〈一句话功能简述〉<br>
 * 〈〉
 *
 * @author 秋水浮萍
 * @create 2020/8/23
 * @since 1.0.0
 */
@Service
@Slf4j
public class SysLogServiceImpl implements SysLogService {

    @Autowired
    private SysLogMapper mapper;

    @Override
    public String claimsNumber(String c) {
        return mapper.claimsNumber(c);
    }

    @Override
    public Integer add(SysLog sysLog) {
        return mapper.add(sysLog);
    }

    @Override
    public boolean save(SysLog sysLog) {

        return false;
    }

    @Override
    public List<SysLog> syslog(String userId) {
        List<SysLog> sysLogs1 = mapper.syslog1(userId);
        List<SysLog> sysLogs2 = mapper.syslog2(userId);
        List<SysLog> sysLogs3 = mapper.syslog3(userId);
        sysLogs1.addAll(sysLogs2);
        sysLogs1.addAll(sysLogs3);
        Collections.sort(sysLogs1, new Comparator<SysLog>() {
            @Override
            public int compare(SysLog o1, SysLog o2) {
                return o2.getCreateTime().compareTo(o1.getCreateTime());
            }
        });
        return sysLogs1;
    }

}